package ConditionPackage;

import Dungeon.ComposedDungeon;
import Dungeon.Subdungeon;
import SquarePackage.Square;
import SquarePackage.TeleportableSquare;
/**
 * this class returns all the Squares from which we can navigate to a chosen Square;
 * @author Florian
 *
 */
public class ReachableCondition implements Condition{
	/**
	 * constructo asks for a reachableSquare, we want to find all startSquares for
	 * @param reachableSquare
	 */
	public ReachableCondition(TeleportableSquare reachableSquare){
		setReachableSquare(reachableSquare);
	}
	private ComposedDungeon<Square, Square, ? extends Subdungeon<? extends Square>> Rootdungeon;
	/**
	 * sets the RootDungeon we want to find our Squares in
	 * @param rootdungeon
	 */
	public void setRootdungeon(
			ComposedDungeon<Square, Square, ? extends Subdungeon<? extends Square>> rootdungeon) {
		Rootdungeon = rootdungeon;
	}
	/**
	 * checker for the condition
	 * true if and only if reachable square is reachable from checksquare, or checkSquare can navigate to reachable Square
	 * | if(isReachable(checkSquare,ReachableSquare) return true
	 */
	@Override
	public boolean checkCondition(Square checkSquare) {
		if(Rootdungeon.isReachable(checkSquare, ReachableSquare)) return true;
		return false;
	}
	/**
	 * gets the square we are using to check the condition
	 * @return Square
	 */
	public Square getReachableSquare() {
		return ReachableSquare;
	}
	/**
	 * set the Square we want to search for
	 * @param reachableSquare
	 */
	public void setReachableSquare(Square reachableSquare) {
		ReachableSquare = reachableSquare;
	}
	private Square ReachableSquare;
	
}
